package com.cloudree.gllib.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuItem;

import com.cloudree.gllib.BaseActivity;
import com.cloudree.gllib.R;
import com.cloudree.gllib.render.TriangleRender;
import com.cloudree.gllib.surface.BaseGLSurface;
import com.cloudree.gllib.util.FragmentUtil;

public class TriangleActivity extends BaseActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_base);

        setTitle("Triangle");
    }

    @Override
    public void initNav() {
        setTitle("Triangle");
    }

    @Override
    public void init() {
        mManager=getSupportFragmentManager();
        fragments= FragmentUtil.getTriangleFragments();
        mManager.beginTransaction()
                .add(R.id.content_container,fragments.get(0))
                .commit();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_triangle,menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int selectedIndex=0;
        switch (item.getItemId()){
            case R.id.triangle_colorful:
                selectedIndex=0;
                break;
//            case R.id.triangle_common:
//                selectedIndex=1;
//                break;
        }
        mManager.beginTransaction()
                .replace(R.id.content_container,fragments.get(selectedIndex))
                .commit();
        index=selectedIndex;
        return super.onOptionsItemSelected(item);
    }
}
